{% extends "base.html" %}

{% load i18n %}

{% block title %}
	{% trans "Draw form" %}
{% endblock %}

{% block content %}
<form action="." method="POST">
	<table id="player_table">
		{{draw_form}}
		<tr><td colspan="4">
			<a href="javascript:jAddPlayer();">{% trans "Add Player" %}</a>
		</td></tr>
		<tr>
			<td>{% trans "Id" %}</td>
			<td>{% trans "Name" %}</td>
			<td>{% trans "Email" %}</td>
			<td>{% trans "Exclusions" %}</td>
		</tr>
	    {{ player_formset.management_form }}
        {% for form in player_formset.forms %}
			<tr>
				<td>
					{{ forloop.counter }}
		        	<input id="id_form-{{ forloop.counter0 }}-draw_id" type="hidden" name="form-{{ forloop.counter0 }}-draw_id" value="{{ forloop.counter }}"/>
				</td>
				<td>
		        	{{ form.name.errors }}
		        	{{ form.name }}
				</td>
				<td>
		        	{{ form.email.errors }}
		        	{{ form.email }}
				</td>
				<td>
		        	{{ form.exclusion_ids.errors }}
		        	{{ form.exclusion_ids }}
				</td>
			</tr>
        {% endfor %}
		<tr id="submit_row"><td>
			<a href="javascript:jAddPlayer();">{% trans "Add Player" %}</a> <input type="submit" value="{% trans "Draw!" %}">
		</td></tr>
	</table>
</form>
{% endblock %}